package com.ocom.webapi.controller;

import com.ocom.common.constant.WebApiServiceUrl;
import com.ocom.common.entity.payconfig.FeeItem;
import com.ocom.common.resp.Result;
import com.ocom.common.vo.payconfig.FeeItemListVo;
import com.ocom.common.vo.payconfig.FeeItemXMVo;
import com.ocom.webapi.feign.PayConfigClientService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * fee_itemController
 *
 * @author junShu
 * @date 2023-08-18 17:02:55
 */
@PreAuthorize("@pms.hasRole('ROLE_WEB')" )
@RestController
public class FeeItemController {

    @Resource
    private PayConfigClientService payConfigClientService;

    /**
     * 查询FeeItem列表
     */
    @PostMapping(WebApiServiceUrl.URL_FeeItemsOnShow)
    public Result feeItemList(@RequestBody FeeItemListVo request) {
//            Page<FeeItem> page = FeeItemService.selectFeeItemPage(pageNumber, pageSize);
        return payConfigClientService.feeItemList(request);
    }

    /**
     * 新增保存FeeItem
     */
    @PostMapping(WebApiServiceUrl.URL_FeeItemsAdd)
    public Result addSave(@RequestBody FeeItem request) {
        return payConfigClientService.addSave(request);
    }

    /**
     * 修改保存FeeItem
     */
    @PostMapping(WebApiServiceUrl.URL_FeeItemsModify)
    public Result editSave(@RequestBody FeeItem feeItem) {
        return payConfigClientService.editSave(feeItem);
    }

    @PostMapping(WebApiServiceUrl.URL_FeeItemsStart)
    public Result startFeeItem(@RequestBody FeeItem feeItem) {
        return payConfigClientService.startFeeItem(feeItem);
    }

    @PostMapping(WebApiServiceUrl.URL_FeeItemsPause)
    public Result pauseFeeItem(@RequestBody FeeItem feeItem) {
        return payConfigClientService.pauseFeeItem(feeItem);
    }

    @PostMapping(WebApiServiceUrl.URL_FeeItemsClose)
    public Result closeFeeItem(@RequestBody FeeItem feeItem) {
        return payConfigClientService.closeFeeItem(feeItem);
    }



//    @PostMapping("/deleteById")
//    public Result deleteById(@RequestBody ComIdVo id) {
////            boolean ret = feeItemService.removeByIds(id.getId());
//        return null;
//    }
//    @PostMapping("/findById")
//    public Result findById(@RequestBody ComIdVo id) {
//        FeeItem resp = feeItemService.getById(id.getId());
//        return null;
//    }

    @PostMapping(WebApiServiceUrl.URL_FeeItemsXmOnShow)
    public Result FeeItemsXmOnShow(@RequestBody FeeItemListVo request) {
        return payConfigClientService.feeItemListXm(request);
    }

    @PostMapping(WebApiServiceUrl.URL_FeeItemsXmAdd)
    public Result FeeItemsXmAdd(@RequestBody FeeItemXMVo request) {
        return payConfigClientService.newFeeItemXM(request);
    }

    @PostMapping(WebApiServiceUrl.URL_FeeItemsXmModify)
    public Result FeeItemsXmModify(@RequestBody FeeItemXMVo request) {
        return payConfigClientService.updateFeeItemXM(request);
    }

}
